package com.xyh.ollama_test.controller;

import com.xyh.ollama_test.service.PermissionService;
import com.xyh.ollama_test.service.SearchInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import reactor.core.publisher.Mono;

@RestController
@RequestMapping("/api/chat")
public class ChatController {
    private final SearchInfo searchInfo;
    private final PermissionService permissionService;

    @Autowired
    public ChatController(SearchInfo searchInfo, PermissionService permissionService) {
        this.searchInfo = searchInfo;
        this.permissionService = permissionService;
    }

    @GetMapping("/{userId}/{text}")
    public Mono<String> chat(@PathVariable String text, @PathVariable String userId) {
        return searchInfo.searchAndGenerateResponse(text, userId);
    }
}